package com.xpmusic.controller.admin;

import com.xpmusic.dao.impl.MusicDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/UpdateDB")
public class UpdateDB extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        String path = this.getServletContext().getRealPath("music");
        System.out.println(path);
        new MusicDaoImpl().updateMusic(path);
        String json="{\"result\":\""+true+"\",\"msg\":\""+"ok"+"\"}";
        out.write(json);
    }
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
